package com.ljy.jymail.product.Util;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Slf4j
@Component
@Aspect
public class logUtils {


    public static String ERROR_LOG_PATH = "D:\\javacode\\jymail\\log";

    @Pointcut("@annotation(com.ljy.jymail.product.annoatation.writeOutPutLog)")
    public void doLog(){
    };


    //输出日志
    @Around("doLog()")
    public void outWriteLog(ProceedingJoinPoint joinPoint){
        try {
            joinPoint.proceed();
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }


    //时间处理
    public String getTime(){
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        String now = simpleDateFormat.format(date);
        return now;
    }



}
